package org.NooLab.openNLP.pragmatics;

import java.util.ArrayList;
import java.util.Vector;

import org.NooLab.structures.nlp.PoStagged;
import org.NooLab.utilities.strings.ArrUtilities;
import org.NooLab.utilities.logging.PrintLog;
import org.NooLab.utilities.strings.StringsUtil;

 
import org.NooLab.openNLP.lang.ParseTools;
import org.NooLab.openNLP.utilities.LanguageProcessorTools;


public abstract class ReasoningPatternsAbs implements ReasoningPatternsIntf{

	// =================================

	// object references ..............

	protected LanguageProcessorTools lptools = new LanguageProcessorTools();
 
 	protected ParseTools parseTools;
 	
	// main variables / properties ....

	String language;
	String basePath;
	
	protected ArrayList<PoStagged> seriesPoStags;

	protected ArrayList<PoStagged> clonedNativeSeries;

	ArrayList<PoStagged> consecutivePartTags = new ArrayList<PoStagged> ();
	protected ArrayList<PoStagged> adverbialconsecutivePartTags = new ArrayList<PoStagged> ();

	protected String patternDescription ="";
	protected int patternIndex = 0;
	
	// constants ......................

	// volatile variables .............

	
	
	// helper objects .................
	ArrUtilities arrutil = new ArrUtilities();
	StringsUtil strgutil = new StringsUtil();

	PrintLog out  ;

	// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
	public ReasoningPatternsAbs( String lang, String basepath, PrintLog outprn){
		out = outprn;
		language = lang ;
		basePath = basepath; // allows access to config files
		
	}
	// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
	
	abstract public void reset(); 	
	
	public ArrayList<PoStagged> getPoSTaggedSequence(  ){
		
		return seriesPoStags;
	}
	
	public void setPoSTaggedSequence( ArrayList<PoStagged> seriespostags ){
		PoStagged ptag ;
		
		seriesPoStags = seriespostags ;
		
		// the object PoStagged contains only primitives, thus, the clone 
		// created here is a really independent clone !
		// note that "clonedNativeSeries" will NOT receive updates too its content by default;
		// this requires additional efforts
		clonedNativeSeries = new ArrayList<PoStagged>();
		// clonedNativeSeries.setSize( seriesPoStags.size()) ;
		
		for (int i=0;i<seriesPoStags.size();i++){
			ptag = (PoStagged) (seriesPoStags.get(i).clone()) ;
			clonedNativeSeries.add(ptag) ;
		}
		
		for (int i=0;i<clonedNativeSeries.size();i++){
			clonedNativeSeries.get(i).setIndex(i);
		}
		
	}
	
	
	
	/**
	 * 
	 * this starts the analysis of the reasoning pattern
	 * 
	 */
	abstract public void describe();

	abstract protected void extractConsecutionParts( ) ;
	
	abstract protected void extractOptionalConsecutionsParts() ; 

	
	// ------------------------------------------------------------------------
	
	public String getPatternDescription() {
		return patternDescription;
	}

	public int getPatternIndex() {
		return patternIndex;
	}

}
